<template>
  <div class="container">
    <!-- 审核功能的对话框 -->
    <el-dialog @close="off" title="题目审核" :visible="lookVisible" width="30%">
      <span>
        <!-- 审核功能的表单 -->
        <el-form ref="Ipt">
          <el-form-item>
            <el-radio v-model="form.chkState" :label="1">通过</el-radio>
            <el-radio v-model="form.chkState" :label="2">拒绝</el-radio>
          </el-form-item>
          <el-form-item>
            <el-input type="textarea" v-model="form.chkRemarks" placeholder="请输入审核意见"></el-input>
          </el-form-item>
        </el-form>
        <div class="status">
          <template> </template>
        </div>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="off">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  props: ['lookVisible'],
  data () {
    return {
      // 提交审核 1 通过 2 拒绝
      form: {
        id: null,
        chkState: 1,
        chkRemarks: null // 原因
      }
    }
  },
  methods: {
    off () {
      this.$emit('update:lookVisible', false)
      this.form.chkState = ''
      this.form.chkRemarks = ''
    },
    // 提交审核 0 待审核 1 通过 2 拒绝
    // 如果审核原因是空就提示操作人员添加审核原因
    // 如果审核意见不为空，则发起审核逻辑
    async submit () {
      if (!this.form.chkRemarks) return this.$message.info('审核意见不可为空')
      const res = await choiceCheck(this.form)
      if (res.status === 200) this.$message.success('成功审核')
      this.off()
      this.$emit('updatePage')
    }
  }
}
</script>

<style scoped lang="less"></style>
